{{% extends "html-template.html" %}}

{{% block body %}}
{{{ super() }}}

{{% if policy.source %}}
based on <a href="{{{ policy.source }}}">{{{ policy.source }}}</a>
{{% endif %}}

<div class="all_controls">
{{% for control in policy.controls -%}}
<div class="one_control">
  <h2>{{{ control.id }}}: {{{ control.title }}}</h2>
  <p>Description: {{{ control.description | safe }}}</p>
  Levels: 
  <ul>
    {{%- for level in control.levels -%}}
    <li>{{{ level }}}</li>
    {{%- endfor %}}
  </ul>
  <p>Automated: {{{ control.automated }}}</p>
  {{% if control.rules -%}}
  Selections:
  <ul>
    {{%- for ruleobj in control.rules -%}}
    {{%- set rule_id = ruleobj|string %}}
    {{%- if rule_id in rules %}}
    <li><a href="https://github.com/ComplianceAsCode/content/tree/master/{{{ rules[rule_id].relative_definition_location }}}">{{{ rule_id }}}</a>: {{{ rules[rule_id].title }}}</li>
    {{%- else %}}
    <li>{{{ rule_id }}} - not available for this product</li>
    {{%- endif -%}}
    {{%- endfor %}}
  </ul>
  {{% else -%}}
  <p>
  <strong>No rules selected</strong>
  </p>
  {{%- endif %}}
</div>  
{{% endfor -%}}
</div>  
{{% endblock %}}
